package drtySyntaxEditor;


import javax.swing.ActionMap;
import javax.swing.InputMap;
import javax.swing.JTextPane;
import javax.swing.KeyStroke;
import javax.swing.text.StyledDocument;

import drtySyntaxEditor.actions.*;

@SuppressWarnings("serial")
public class DrtySyntaxEditor extends JTextPane {		
	
	private int tabSize = 4;
	
	public DrtySyntaxEditor() {
		super(new DrtySyntaxDocument());
		this.applyActions();
	}
	
	public DrtySyntaxEditor(StyledDocument d) {
		this();
	}
	
	public void applyActions() {

		InputMap inMap = this.getInputMap();
		ActionMap acMap = this.getActionMap();//System.out.println(this.getActions());
		
		inMap.put(KeyStroke.getKeyStroke("shift TAB"), "ActionUnindent");
		acMap.put("ActionIndent", new ActionUnindent(this));
		
		inMap.put(KeyStroke.getKeyStroke("TAB"), "ActionIndent");
		acMap.put("ActionUnindent", new ActionIndent(this));
		
		/*this.getInputMap().put(KeyStroke.getKeyStroke("TAB"), "TAB");
		this.getActionMap().put("TAB", new AbstractAction() {	
			public void actionPerformed(ActionEvent arg0) {
				System.out.println("Hit tab");
			}
		});*/
	}
	
	
	public void executeAction(String actionName) {
		ActionMap acMap = this.getActionMap();
		this.getActions();
	}
	
	public int getTabSize() {
		return tabSize;		
	}
	
	public void setTabSize(int s) {
		this.tabSize = s;
	}
	
}
